110. 平衡二叉树

https://leetcode.cn/problems/balanced-binary-tree/description/



int BTHight(struct TreeNode*root)
{
    if(root==NULL)
        return 0;
    
    int leftHight=BTHight(root->left);
    int rightHight=BTHight(root->right);

    return leftHight>rightHight?leftHight+1:rightHight+1;
}


bool isBalanced(struct TreeNode* root){
    if(root==NULL)
    {
        return true;
    }
    int leftHight=BTHight(root->left);
    int rightHight=BTHight(root->right);
    if(abs(leftHight-rightHight)>1)
    {
        return false;
    }


    return isBalanced(root->left)&&isBalanced(root->right);

}